package wojtek_ckm;
import java.io.*;
import java.net.*;
public class Serwerek {
   
	
	
	public static void main(String args[]) {

		 DataInputStream input = null;
		 PrintStream output = null;

		
		 try {
			 ServerSocket mojSerwer = new ServerSocket(2501);
			 Socket clientSocket = mojSerwer.accept();
		     
			 System.out.println("Server polaczony \n");

		    	String imie;
		    	String linia;
		       input = new DataInputStream(clientSocket.getInputStream());
		       output = new PrintStream(clientSocket.getOutputStream());

		       output.println("zeby wyjsc wpisz exit ");
		       output.println("podaj imie: ");
imie = input.readLine();
output.println("Witaj "+ imie);
while (true){
	linia = input.readLine();
	output.println(imie + " - "+ linia);

	if(linia.startsWith("exit")) break;
	

}
output.close();
input.close();
clientSocket.close();
mojSerwer.close();

		    }
		    catch (IOException e) {
		       System.out.println(e);
		    }
		    
		
		     output.println("jest serwer");
		    
	
    } 
}
